package com.printeverywhere.action;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.ActionContext;
import com.printeverywhere.delegator.LocationCategoriesServiceDelegator;
import com.printeverywhere.delegator.MiscellaneousFeesServiceDelegator;
import com.printeverywhere.dto.LocationCategories;
import com.printeverywhere.dto.MiscellaneousFees;
import com.printeverywhere.util.AdminConstants;
import com.printeverywhere.util.SearchListCriteria;

public class OwnerDetailsAction extends AdminSystemSetup{
	Logger logger = Logger.getLogger(OwnerDetailsAction.class);
	private List<LocationCategories> countryList = new ArrayList<LocationCategories>();
	private List<LocationCategories> locationList = new ArrayList<LocationCategories>();
	SearchListCriteria searchListCriteria = new SearchListCriteria();
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	public String execute() throws Exception{
		if (logger.isDebugEnabled()) {
			logger.debug("execute() - start"); //$NON-NLS-1$
		}
		getLocation(countryList, AdminConstants.TWO_NUMBER, AdminConstants.ZERO_NUMBER);
		if (logger.isDebugEnabled()) {
			logger.debug("execute() - end"); //$NON-NLS-1$
		}
		return SUCCESS;
	}

	public void getLocation(List<LocationCategories> list, int level, int categoryId){
		locationList = (List<LocationCategories>) ActionContext.getContext().getApplication().get(AdminConstants.LOCATIONCATEGORIES);
		list.clear();
		for (Iterator<LocationCategories> iterator = locationList.iterator(); iterator
				.hasNext();) {
			LocationCategories locationCategories = (LocationCategories) iterator
					.next();

				if(categoryId > 0){
					if(locationCategories.getLocationCategories().getCategoryId() == categoryId){
						if (locationCategories.getLevel() == level){
							list.add(locationCategories);
						}
					}
				}else {
					if (locationCategories.getLevel() == level){
						list.add(locationCategories);
					}
				}
		}
	}
	public List<LocationCategories> getCountryList() {
		return countryList;
	}
	public void setCountryList(List<LocationCategories> countryList) {
		this.countryList = countryList;
	}

}
